C NOTE: Read the "MPW Fortrans" section of "About Compilers"
C before compiling AF programs that use FaceWare modules.

C FaceIt 2.04 Demonstration Program
C ©FaceWare 1989-92.  All Rights Reserved.
C1 - run program to see on-line comments

	GLOBAL DEFINE
	include "Types.inc"
	include "QuickDraw.inc"
	include "ToolUtils.inc"
	include "Controls.inc"
	include "Events.inc"
	include "OSUtils.inc"
	include "OSEvents.inc"
	include "SegLoad.inc"
	include "Files.inc"
	include "Resources.inc"
	include "FaceStorAF.inc"
	END
C2
	include "FaceProcAF.inc"

      PROGRAM fDemoAF
	implicit none
      record /FaceRec/ fRec
      common/FaceStuff/fRec
	integer*1 keys(16)
	integer*2 i,mode
	integer*4 oldCount,newCount
	character*256 fileName
C3
      fRec.uName = 'fDemo.Rsrc'
C4,5
      call FaceIt(0,DoInit,515,0,0,0)
C6
	call FaceIt(0,NewWnd,1030,1,0,0)
C7
      do while (.true.)
        call FaceIt(0,DoLoop,0,0,0,0)
C8
C9
        if (fRec.uMenuID == 101) then
	    if (fRec.uMenuItem == 1) then
	      fRec.uString = 'Demonstration of the use of FaceIt'
     +//char(13)//'to support program-wide features.'
	      call FaceIt(0,ShoStr,3,12,(1 + (409*65536)),0)
	    end if
C10
	  else if ((fRec.uMenuID >= 105).and.(fRec.uMenuID <= 107)) then
C11
	    if (fRec.uMenuItem == 1) then
	      call SysBeep(%val2(5))
	    else if (fRec.uMenuItem == 2) then
	      call SysBeep(%val2(5))
	      call SysBeep(%val2(5))
	    else if (fRec.uMenuItem == 3) then
	      call SysBeep(%val2(5))
	      call SysBeep(%val2(5))
	      call SysBeep(%val2(5))
C12
	    else if (fRec.uMenuItem == 8) then
C13
		call FaceIt(0,ShoAlt,1010,0,1,1)
		mode = fRec.uResult
		oldCount = 0
		if (mode > 1) then
		  do while (.true.)
C14
		    newCount = TickCount()
		    if (newCount - oldCount > 180) then
		      call SysBeep(%val2(5))
			oldCount = newCount
		    end if
C15
		    if (mode == 2) then
		      if (GetNextEvent(%val2(-1),fRec.fEvent) <> 0) then
			  if ((fRec.fEvent(1) == 6).or.
     +		   (fRec.fEvent(1) == 15)) then
			    call FaceIt(0,DoEvnt,0,0,0,0)
			  else if (fRec.fEvent(1) == 5) then
			    exit
			  end if
			end if
		    end if
C16
		    if (mode == 3) then
		      call GetKeys(keys)
			if ((BitTst(keys,%val4(61))<>0)
     +		 .and.(BitTst(keys,%val4(48))<>0)) then
			  call FlushEvents(%val2(62),%val2(0))
			  exit
			end if
		    end if
		  end do
		end if
	    end if
C17
	  else if (fRec.uMenuID == 1030) then
	    if (fRec.wcHit > 3) then
	      call FaceIt(0,GetCtl,1030,0,1,4)
	      call FaceIt(0,PopMen,107,fRec.cRect(1)-5,fRec.cRect(2)-11,0)
		fRec.wcHit = fRec.uMenuItem
	    end if
	    if (fRec.wcHit > 0) then
	      do (i = 1,fRec.wcHit)
		  call SysBeep(%val2(5))
		end do
	    end if
C18
	  else if (fRec.uMenuID == 1100) then
	    if (fRec.uMenuItem == 2) then
	      if (fRec.fActiveWnd == 0) then
		  fRec.uString = 'No Window'
		else if (fRec.fActiveID <> 1200) then
		  fRec.uString = 'Non-ViewIt Window'
		else if (fRec.fActiveResID == 1010) then
		  fRec.uString = 'Editor Window'
		else if (fRec.fActiveResID == 1020) then
		  fRec.uString = 'Clipboard Window'
		else if (fRec.fActiveResID == 1030) then
		  fRec.uString = 'Beeps Window'
		end if
		call FaceIt(0,SetItm2,105,10,3,0)
C19
	    else if (fRec.uMenuItem == 512) then
	      if ((fRec.uString == 'TEXT').and.(fRec.uResult == 1)) then
		  fileName = fRec.uName
		  call FaceIt(0,GetCtl,1010,0,1,1)
		  fRec.uName = fileName
		  call FaceIt(fRec.cControl,1551,0,1,0,0) !OpnCTxt
		end if
	    end if
	  end if
      end do
      end
